Skip to content

Add crispEdges option for SVG output in JavaScript - #134

Open
yuriyapostol wants to merge 2 commits into
kazuhikoarase:masterfrom
yuriyapostol:shape-rendering
Open

Add crispEdges option for SVG output in JavaScript#134
yuriyapostol wants to merge 2 commits into
kazuhikoarase:masterfrom
yuriyapostol:shape-rendering

Conversation

@yuriyapostol

Copy link
Copy Markdown

This PR adds a crispEdges option to createSvgTag() in the JavaScript implementation.

The new option supports three modes:

  • 'auto' (default): adds shape-rendering="crispEdges" only for whole-number cellSize values
  • true: always adds shape-rendering="crispEdges"
  • false: never adds shape-rendering="crispEdges"

This fixes the rendering issue described in the PHP PR #104, while implementing the solution for the JavaScript version.

The default auto behavior keeps sharp rendering where it makes sense and avoids unwanted artifacts for fractional sizes:

  • for whole-number cell sizes, cell boundaries align with the pixel grid, so crispEdges does not introduce geometric distortion
  • for fractional cell sizes, forcing crispEdges can shift cell boundaries to the pixel grid and distort the geometry
  • in practice, fractional cell sizes are usually not a meaningful target for QR modules anyway

Changes:

  • add crispEdges option to createSvgTag(opts)
  • update JavaScript distribution files
  • update TypeScript declarations
  • update README
  • add test coverage for auto, forced enable, and forced disable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant